import { build } from '../test/helper'

async function main() {
    const app = await build({ after: () => {} } as any)
    try {
        console.log('App built')
        const loginRes = await app.inject({
            method: 'POST',
            url: '/api/auth/admin/login',
            payload: { email: 'admin@example.com', password: 'password123' }
        })
        console.log('login status', loginRes.statusCode, loginRes.payload)
        const loginData = JSON.parse(loginRes.payload)
        const token = loginData.data?.token
        console.log('token:', token)

        const verifyRes = await app.inject({ method: 'POST', url: '/api/auth/verify', payload: { token } })
        console.log('verify status', verifyRes.statusCode, verifyRes.payload)
    } finally {
        await app.close()
    }
}

main().catch(err => console.error(err))
